package com.pizza.control;

import java.io.Serializable;
import java.rmi.RemoteException;
import java.util.ArrayList;

import javax.faces.component.UIData;
import javax.faces.context.FacesContext;

import com.pizza.abstrait.AbstractPizza;
import com.pizza.database.PizzaManagerClient;

/**
 * Class PizzasBean
 *
 */
public class PizzasBean extends AbstractPizza implements Serializable
{
	private UIData dataTable;
   
	private ArrayList<PizzasBean> pizzas;
	private ArrayList<AbstractPizza> pizzasPerso;
	private ArrayList<AbstractPizza> nosPizzas;
		

	public PizzasBean()
	{
		pizzas = new ArrayList<PizzasBean>();
		pizzas.add(this);
		FacesContext context = FacesContext.getCurrentInstance();
		ClientBean client = (ClientBean) context.getExternalContext().getSessionMap()
		.get("clientBean");
		try
		{
			//pizzas = new PizzaManager().getListPizzas();
			nosPizzas = PizzaManagerClient.GetPizzaManager().getListPizzas();
			pizzasPerso = PizzaManagerClient.GetPizzaManager().getListPizzasPersos(client);
		} catch (RemoteException e)
		{
			e.printStackTrace();
		}
	}

	public void setPizzas(ArrayList<PizzasBean> pizzas) {
		this.pizzas = pizzas;
	}

	public ArrayList<PizzasBean> getPizzas()
	{
		return pizzas;
	}

	public UIData getDataTable()
	{
		return dataTable;
	}

	public void setDataTable(UIData dataTable)
	{
		this.dataTable = dataTable;
	}

	public ArrayList<AbstractPizza> getNosPizzas() {
		return nosPizzas;
	}

	public void setNosPizzas(ArrayList<AbstractPizza> nosPizzas) {
		this.nosPizzas = nosPizzas;
	}

	public ArrayList<AbstractPizza> getPizzasPerso() {
		FacesContext context = FacesContext.getCurrentInstance();
		ClientBean client = (ClientBean) context.getExternalContext().getSessionMap()
		.get("clientBean");
		try {
			pizzasPerso = PizzaManagerClient.GetPizzaManager().getListPizzasPersos(client);
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		return pizzasPerso;
	}

	public void setPizzasPerso(ArrayList<AbstractPizza> pizzasPerso) {
		this.pizzasPerso = pizzasPerso;
	}

}
